// pages/service/index.js
const app = getApp()
Page({
  data: {
    serverHost: app.config.serverHost,
    goodsList: '',
    active: 0,
    tabList: ["全部", '时令水果', '新鲜蔬菜', '肉禽蛋类', '海鲜水产', '酒水饮料','零食熟食', '粮油速食','纸品清洁']
  },
  onChange(event) {
    if (event.detail == "0") {
      wx.redirectTo({
        url: './index',
      })
    } else if (event.detail == "1") {
      wx.redirectTo({
        url: './bill/index',
      })
    } else if (event.detail == "2") {
      wx.redirectTo({
        url: './servicer/servicer',
      })
      }
  },
  changeActive(a){
    let item = this.data.filterData
    let i = item.filter(e => {
      return a.detail.title == '全部' ? item : e.class == a.detail.title
    })
    this.setData({
      goodsList: i
    })
  },
  onLoad: function (options) {
    wx.showLoading({
      title: '加载中',
    })
    app.api.getData('admin/goodslist', 'none', res=>{
      this.setData({
        goodsList:res.data,
        filterData:res.data
      })
      wx.hideLoading()
    })
  }
})